//
//  TopImageBottomTitleButton.m
//  UILbrary
//
//  Created by mac on 16/7/20.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "TopImageBottomTitleButton.h"

@implementation TopImageBottomTitleButton
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self configSubViews];
    }
    return self;
}

- (void)configSubViews{
    CGFloat const buttonSize = 2/3.0 * self.frame.size.height;
    CGFloat const titleHeit = 1/3.0 *self.frame.size.height;
    self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, buttonSize, buttonSize)];
    self.button.center = CGPointMake(self.bounds.size.width/2.0, CGRectGetMinY(self.bounds) + buttonSize/2.0);

    [self addSubview:self.button];
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.origin.x, CGRectGetMaxY(self.button.frame), self.frame.size.width, titleHeit)];
    self.title.backgroundColor = [UIColor clearColor];
    self.title.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.title];
}


@end
